package com.java.example.base

import android.os.Bundle
import androidx.annotation.LayoutRes
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding

/**
 * TODO 基类Activity
 * @param VB ViewDataBinding
 * @param layoutId 视图Id
 * @author chenll
 * @date 2024/5/17
 */
abstract class BaseActivity<VB : ViewDataBinding>(@LayoutRes private var layoutId: Int) : AppCompatActivity() {

    protected lateinit var binding: VB

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = DataBindingUtil.setContentView(this, layoutId)
    }

    override fun onDestroy() {
        super.onDestroy()
        binding.unbind()
    }

    open inner class ClickableBase {
        open fun back() {
            onBackPressedDispatcher.onBackPressed()
        }
    }
}
